//
//  ViewController.h
//  hunba
//
//  Created by 孙智慧 on 15/12/31.
//  Copyright © 2015年 孙智慧. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MPNowPlayingInfoCenter.h>
#import <MediaPlayer/MPMediaItem.h>
#import "CoverImgView.h"
#import "HJCActionSheet.h"
#import "TBloaderURLConnection.h"
#import "TBVideoRequestTask.h"
#import "ZYMusicTool.h"
#import "ZYAudioManager.h"
#import "ZYMusic.h"

#import "UIMarqueeBarView.h"
#import "LoginOperation.h"
#import "FansOperation.h"
#import "CFDanmakuView.h"

#import "WXApi.h"
#import "DownLoad.h"
#import "DownLoadObjects.h"

FOUNDATION_EXPORT NSString *const kTBPlayerStateChangedNotification;
//播放器的几种状态
typedef NS_ENUM(NSInteger, TBPlayerState)
{
    TBPlayerStateBuffering = 1,
    TBPlayerStatePlaying   = 2,
    TBPlayerStateStopped   = 3,
    TBPlayerStatePause     = 4
};

@interface MusicPlayController : UIViewController<AVAudioPlayerDelegate,HJCActionSheetDelegate,FxOperationDelegate,CFDanmakuDelegate,UITextFieldDelegate,UITableViewDataSource,UITableViewDelegate,TBloaderURLConnectionDelegate>
{
    CGAffineTransform oldTransform;
    
    NSString *_totalTime;
    
    NSDateFormatter *_dateFormatter;
    
    BOOL isInited;
    
    BOOL isAddTime;
    
    BOOL isLocal;
    
    BOOL isChangeQuality;

    NetWorkOperation *operation;
    
    NSInteger loop;  //0 单曲循环 1 列表播放 2 交叉循环
    
    CFDanmakuView *_danmakuView;
    
    NSInteger flag;
    
    HJCActionSheet *sheet;
    
    NSMutableArray  *qualityArray;
    
    // 1 wifi 2 4G 0 没有网络
    NSString *state;
    
    NSDictionary *downloadQuality;

}
+(MusicPlayController *)sharedMyClass;
-(void) playOrPause;
-(void) nextMusic;
-(void) preMusic;

@property (nonatomic,strong) NSString *playMode;

@property (nonatomic) bool isRoationing;

@property (nonatomic, readonly) TBPlayerState mState;
@property (nonatomic, strong) TBloaderURLConnection *resouerLoader;
@property (nonatomic , strong) AVURLAsset     *musicURLAsset;
@property (nonatomic , strong) AVAsset        *musicAsset;
@property (nonatomic , strong) AVPlayer *player;
@property (nonatomic , strong) AVPlayerItem *playerItem;
@property (nonatomic , strong) id playbackTimeObserver;
@property (nonatomic ) BOOL           isPauseByUser; //是否被用户暂停
@property (nonatomic ) BOOL           isLocalVideo; //是否播放本地文件
@property (nonatomic ) BOOL           isFinishLoad; //是否下载完毕

@property (nonatomic ,weak) IBOutlet UISlider *videoSlider;

@property (nonatomic, strong) ZYMusic *playingMusic;

@property (weak, nonatomic) IBOutlet CoverImgView *coverImgView;

@property (weak, nonatomic) IBOutlet UIImageView *bgImgView;

@property (weak, nonatomic) IBOutlet UIImageView *imgViewChangZhen;

@property (weak, nonatomic) IBOutlet UIProgressView *videoProgress;

@property (weak, nonatomic) IBOutlet UIButton *btnPlay;

@property (weak, nonatomic) IBOutlet UIButton *btnNext;

@property (weak, nonatomic) IBOutlet UIButton *btnPrv;
 
@property (weak, nonatomic) IBOutlet UILabel *lblMusicName;

- (void) initMusic:(NSString *)fileUrl;

- (IBAction)videoSlierChangeValue:(id)sender;

- (IBAction)videoSlierChangeValueEnd:(id)sender;

@property (weak, nonatomic) IBOutlet UIImageView *imgHead;

@property (weak, nonatomic) IBOutlet UILabel *lbldjCode;

@property (weak, nonatomic) IBOutlet UILabel *lblNickName;

@property (weak, nonatomic) IBOutlet UILabel *lblMusicCount;

@property (weak, nonatomic) IBOutlet UILabel *lblFocusCount;

@property (weak, nonatomic) IBOutlet UILabel *lblFansCount;

@property (weak, nonatomic) IBOutlet UIView *viewQualityList;

@property (weak, nonatomic) IBOutlet UIView *viewmaku;

@property (weak, nonatomic) IBOutlet UITextField *txtCommentText;

@property (weak, nonatomic) IBOutlet UIView *viewSendMaku;

@property (weak, nonatomic) IBOutlet UIButton *btnTm;

@property (weak, nonatomic) IBOutlet UILabel *lblTotltSec;

@property (weak, nonatomic) IBOutlet UILabel *lblCurrSec;

@property (weak, nonatomic) IBOutlet UIButton *btnLoop;

@property (weak, nonatomic) IBOutlet UIButton *btnLike;

@property (weak, nonatomic) IBOutlet UIButton *btnQuality;
@end

